package com.information.manage.base.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.information.manage.base.model.entity.Zhanqu;
import com.information.manage.base.model.query.PageQuery;
import com.information.manage.base.sevice.ZhanquService;
import com.information.manage.basic.common.result.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/phm/base/zhanqu/")
public class ZhanquController {

    @Resource
    private ZhanquService zhanquService;

    @GetMapping("getZhanqu")
    public Result<Page<Zhanqu>> getZhanquList(PageQuery pageQuery){
        Page<Zhanqu> page = zhanquService.getUsersByPage(pageQuery.getCurPage(), pageQuery.getPageSize(), pageQuery.getName());
        return Result.ok(page);
    }

    @GetMapping("find/{id}")
    public Result<Zhanqu> findById(@PathVariable Integer id){
        return Result.ok(zhanquService.getById(id));
    }

    @PostMapping("add")
    public Result<Boolean> save(@RequestBody Zhanqu zhanqu){
        return Result.ok(zhanquService.save(zhanquService.addZhanqu(zhanqu)));
    }

    @PostMapping("update")
    public Result<Boolean> update(@RequestBody Zhanqu zhanqu){
        return Result.ok(zhanquService.updateZhanquById(zhanqu));
    }

    @DeleteMapping("delete")
    public Result<Boolean> delete(@RequestBody List<Integer> ids){
        return Result.ok(zhanquService.removeByIds(ids));
    }


}
